/*
 *  ape.c
 *  compiler
 *
 */

#include "ape.h"

int is_ape_in_final_state() {
	Machine m = ape_parser.current_machine;
	int i;
	for(i=0; i< 100; i++) {
		if (m.current_state == m.final_states[i])
			return 1;
		else if (m.final_states[i] == -1)
			break;
	}
	return 0;
}

void change_ape_machine(int machine_id, int state) {
	(*semantic_functions_machines[ape_parser.current_machine.machine_id][ape_parser.current_machine.current_state][machine_id])();

	ape_parser.current_machine = ape_parser.machines[machine_id];
	ape_parser.current_machine.current_state = state;
}

void change_ape_machine_pop(int machine_id, int state) {
	(*semantic_funcions_saida[ape_parser.current_machine.machine_id][ape_parser.current_machine.current_state])();

	ape_parser.current_machine = ape_parser.machines[machine_id];
	ape_parser.current_machine.current_state = state;
}

void go_to_state(int next_state) {
	(*semantic_functions_tokens[ape_parser.current_machine.machine_id][ape_parser.current_machine.current_state][ape_get_token_id()])();

	ape_parser.current_machine.current_state = next_state;
}

int ape_consume_token() {
	int machine_id;
	int token_id = ape_get_token_id();
	Machine current_machine = ape_parser.current_machine;

	int next_state = current_machine.token_transitions[current_machine.current_state][token_id];

	printf("%d: (%d,%d) -> %d\t\t(Token ID: %d)\n", current_machine.machine_id, current_machine.current_state, token_id, next_state, ape_get_token_id());

	if (next_state == APE_INVALID_STATE) {
		// could not read the token, let's check if we can change the machine

		machine_id = machine_id_consume_token(token_id);
		next_state = current_machine.machine_transitions[current_machine.current_state][machine_id];

		if (machine_id != APE_INVALID_STATE) {

			// change the current machine
			change_ape_machine(machine_id, ape_parser.machines[machine_id].initial_state);

			current_machine.current_state = next_state;

			// enqueue the current machine
			push_apestack(current_machine);

			return ape_consume_token();

		} else if (is_ape_in_final_state() && !is_apestack_empty()) { // check if there's a machine in the queue

			// retrieve the machine in its original state
			Machine m = pop_apestack();
			change_ape_machine_pop(m.machine_id, m.current_state);

			return ape_consume_token();

		} else {
			// could not consume the token in any machine
			return 0;
		}

	} else {
		go_to_state(next_state);
		return 1;
	}

	return 0;
}

int machine_id_consume_token(int token_id){

	int i;
	Machine m, current;
	current = ape_parser.current_machine;
	for (i=0; i < APE_TOTAL_MACHINES; i++) {
		m = ape_parser.machines[i];
		if (m.token_transitions[m.initial_state][token_id] != APE_INVALID_STATE || can_machine_consume_machine(m)) {

			if (current.machine_transitions[current.current_state][m.machine_id] != APE_INVALID_STATE) {
				//ape_parser.current_machine.current_state = current.machine_transitions[current.current_state][m.machine_id];
				return m.machine_id;
			}

		}
	}
	return APE_INVALID_STATE;
}

int can_machine_consume_machine(Machine m) {
	int i;
	for (i=0; i < APE_TOTAL_MACHINES; i++){
		if (m.machine_transitions[m.initial_state][i] != APE_INVALID_STATE) {
			return 1;
		}
	}
	return 0;
}

int ape_get_token_id(){

	switch ((int)token.type) {

		case TOKEN_TYPE_RESERVED_WORD:
			if (strcmp(token.value, "funcao") == 0) {
				return APE_TOKEN_FUNCAO_ID;
			}

			if (strcmp(token.value, "procedimento") == 0) {
				return APE_TOKEN_PROCEDIMENTO_ID;
			}

			if (strcmp(token.value, "registro") == 0) {
				return APE_TOKEN_REGISTRO_ID;
			}

			if (strcmp(token.value, "programa") == 0) {
				return APE_TOKEN_PROGRAMA_ID;
			}

			if (strcmp(token.value, "eh") == 0) {
				return APE_TOKEN_EH_ID;
			}

			if (strcmp(token.value, "inteiro") == 0) {
				return APE_TOKEN_INTEIRO_ID;
			}

			if (strcmp(token.value, "real") == 0) {
				return APE_TOKEN_REAL_ID;
			}

			if (strcmp(token.value, "string") == 0) {
				return APE_TOKEN_STRING_ID;
			}

			if (strcmp(token.value, "booleano") == 0) {
				return APE_TOKEN_BOOLEANO_ID;
			}

			if (strcmp(token.value, "inicio") == 0) {
				return APE_TOKEN_INICIO_ID;
			}

			if (strcmp(token.value, "fim") == 0) {
				return APE_TOKEN_FIM_ID;
			}

			if (strcmp(token.value, "retorna") == 0) {
				return APE_TOKEN_RETORNA_ID;
			}

			if (strcmp(token.value, "fimRegistro") == 0) {
				return APE_TOKEN_FIMREGISTRO_ID;
			}

			if (strcmp(token.value, "se") == 0) {
				return APE_TOKEN_SE_ID;
			}

			if (strcmp(token.value, "enquanto") == 0) {
				return APE_TOKEN_ENQUANTO_ID;
			}

			if (strcmp(token.value, "entrada") == 0) {
				return APE_TOKEN_ENTRADA_ID;
			}

			if (strcmp(token.value, "saida") == 0) {
				return APE_TOKEN_SAIDA_ID;
			}

			if (strcmp(token.value, "loop") == 0) {
				return APE_TOKEN_LOOP_ID;
			}

			if (strcmp(token.value, "fimLoop") == 0) {
				return APE_TOKEN_FIMLOOP_ID;
			}

			if (strcmp(token.value, "entao") == 0) {
				return APE_TOKEN_ENTAO_ID;
			}

			if (strcmp(token.value, "senaoSe") == 0) {
				return APE_TOKEN_SENAOSE_ID;
			}

			if (strcmp(token.value, "senao") == 0) {
				return APE_TOKEN_SENAO_ID;
			}

			if (strcmp(token.value, "fimSe") == 0) {
				return APE_TOKEN_FIMSE_ID;
			}

			if (strcmp(token.value, "verdadeiro") == 0) {
				return APE_TOKEN_VERDADEIRO_ID;
			}

			if (strcmp(token.value, "falso") == 0) {
				return APE_TOKEN_FALSO_ID;
			}

			if (strcmp(token.value, "E") == 0) {
				return APE_TOKEN_E_ID;
			}

			if (strcmp(token.value, "OU") == 0) {
				return APE_TOKEN_OU_ID;
			}

			break;

		case TOKEN_TYPE_IDENTIFIER:
			return APE_TOKEN_IDENTIFICADOR_ID;;
			break;

		case TOKEN_TYPE_INT_NUMBER:
			return APE_TOKEN_NUMERO_ID;
			break;

		case TOKEN_TYPE_SPECIAL:
			if (strcmp(token.value, "(") == 0) {
				return APE_TOKEN_ABRE_PARENTESES_ID;
			}

			if (strcmp(token.value, ")") == 0) {
				return APE_TOKEN_FECHA_PARENTESES_ID;
			}

			if (strcmp(token.value, "[") == 0) {
				return APE_TOKEN_ABRE_COLCHETES_ID;
			}

			if (strcmp(token.value, ",") == 0) {
				return APE_TOKEN_VIRGULA_ID;
			}

			if (strcmp(token.value, "]") == 0) {
				return APE_TOKEN_FECHA_COLCHETES_ID;
			}

			if (strcmp(token.value, ":=") == 0) {
				return APE_TOKEN_ATRIBUICAO_ID;
			}

			if (strcmp(token.value, ";") == 0) {
				return APE_TOKEN_PONTO_E_VIRGULA_ID;
			}

			if (strcmp(token.value, "+") == 0) {
				return APE_TOKEN_SOMA_ID;
			}

			if (strcmp(token.value, "-") == 0) {
				return APE_TOKEN_SUBTRACAO_ID;
			}


			if (strcmp(token.value, "*") == 0) {
				return APE_TOKEN_MULTIPLICACAO_ID;
			}

			if (strcmp(token.value, "/") == 0) {
				return APE_TOKEN_DIVISAO_ID;
			}

			if (strcmp(token.value, ">") == 0) {
				return APE_TOKEN_MAIOR_ID;
			}

			if (strcmp(token.value, "<") == 0) {
				return APE_TOKEN_MENOR_ID;
			}

			if (strcmp(token.value, "<=") == 0) {
				return APE_TOKEN_MENOR_IGUAL_ID;
			}

			if (strcmp(token.value, ">=") == 0) {
				return APE_TOKEN_MAIOR_IGUAL_ID;
			}

			if (strcmp(token.value, "=") == 0) {
				return APE_TOKEN_IGUAL_ID;
			}

			if (strcmp(token.value, "!=") == 0) {
				return APE_TOKEN_DIFERENTE_ID;
			}

			break;

		case TOKEN_TYPE_STRING:
			return APE_TOKEN_STRINGLITERAL_ID;
			break;

		default:
			break;
	}

	return -1;
}

//////////////////////////////////////////////////////////
////////// GENERATED BY RADIANT FIRE LOADER //////////////
//////////////////////////////////////////////////////////

void init_ape_machines() {
	/* load machines */
  Machine elemento, declaracao, comando, expressao;


	/* Machine 0: elemento */
  elemento.machine_id = APE_MACHINE_ELEMENTO_ID; // 0
  elemento.initial_state = 0;
  elemento.current_state = 0;
  initialize_machine_transitions(&elemento);
	elemento.final_states[0] = 13;
	elemento.final_states[1] = -1;

	/* token transitions */
	elemento.token_transitions		[0][APE_TOKEN_FUNCAO_ID]		=		1;
	elemento.token_transitions		[0][APE_TOKEN_PROCEDIMENTO_ID]		=		2;
	elemento.token_transitions		[0][APE_TOKEN_PROGRAMA_ID]		=		4;
	elemento.token_transitions		[0][APE_TOKEN_REGISTRO_ID]		=		3;
	elemento.token_transitions		[1][APE_TOKEN_IDENTIFICADOR_ID]		=		5;
	elemento.token_transitions		[2][APE_TOKEN_IDENTIFICADOR_ID]		=		22;
	elemento.token_transitions		[3][APE_TOKEN_IDENTIFICADOR_ID]		=		17;
	elemento.token_transitions		[4][APE_TOKEN_IDENTIFICADOR_ID]		=		6;
	elemento.token_transitions		[5][APE_TOKEN_ABRE_PARENTESES_ID]		=		7;
	elemento.token_transitions		[6][APE_TOKEN_EH_ID]		=		8;
	elemento.token_transitions		[7][APE_TOKEN_BOOLEANO_ID]		=		9;
	elemento.token_transitions		[7][APE_TOKEN_FECHA_PARENTESES_ID]		=		10;
	elemento.token_transitions		[7][APE_TOKEN_IDENTIFICADOR_ID]		=		9;
	elemento.token_transitions		[7][APE_TOKEN_INTEIRO_ID]		=		9;
	elemento.token_transitions		[7][APE_TOKEN_REAL_ID]		=		9;
	elemento.token_transitions		[7][APE_TOKEN_STRING_ID]		=		9;
	elemento.token_transitions		[8][APE_TOKEN_INICIO_ID]		=		11;
	elemento.token_transitions		[9][APE_TOKEN_ABRE_COLCHETES_ID]		=		20;
	elemento.token_transitions		[9][APE_TOKEN_IDENTIFICADOR_ID]		=		19;
	elemento.token_transitions		[10][APE_TOKEN_EH_ID]		=		12;
	elemento.token_transitions		[11][APE_TOKEN_FIM_ID]		=		13;
	elemento.token_transitions		[12][APE_TOKEN_RETORNA_ID]		=		14;
	elemento.token_transitions		[15][APE_TOKEN_INICIO_ID]		=		16;
	elemento.token_transitions		[16][APE_TOKEN_FIM_ID]		=		0;
	elemento.token_transitions		[17][APE_TOKEN_INICIO_ID]		=		18;
	elemento.token_transitions		[18][APE_TOKEN_FIMREGISTRO_ID]		=		0;
	elemento.token_transitions		[19][APE_TOKEN_FECHA_PARENTESES_ID]		=		10;
	elemento.token_transitions		[19][APE_TOKEN_VIRGULA_ID]		=		26;
	elemento.token_transitions		[20][APE_TOKEN_NUMERO_ID]		=		21;
	elemento.token_transitions		[21][APE_TOKEN_FECHA_COLCHETES_ID]		=		9;
	elemento.token_transitions		[22][APE_TOKEN_ABRE_PARENTESES_ID]		=		23;
	elemento.token_transitions		[23][APE_TOKEN_BOOLEANO_ID]		=		24;
	elemento.token_transitions		[23][APE_TOKEN_FECHA_PARENTESES_ID]		=		25;
	elemento.token_transitions		[23][APE_TOKEN_IDENTIFICADOR_ID]		=		24;
	elemento.token_transitions		[23][APE_TOKEN_INTEIRO_ID]		=		24;
	elemento.token_transitions		[23][APE_TOKEN_REAL_ID]		=		24;
	elemento.token_transitions		[23][APE_TOKEN_STRING_ID]		=		24;
	elemento.token_transitions		[24][APE_TOKEN_ABRE_COLCHETES_ID]		=		30;
	elemento.token_transitions		[24][APE_TOKEN_IDENTIFICADOR_ID]		=		29;
	elemento.token_transitions		[25][APE_TOKEN_EH_ID]		=		27;
	elemento.token_transitions		[26][APE_TOKEN_BOOLEANO_ID]		=		9;
	elemento.token_transitions		[26][APE_TOKEN_IDENTIFICADOR_ID]		=		9;
	elemento.token_transitions		[26][APE_TOKEN_INTEIRO_ID]		=		9;
	elemento.token_transitions		[26][APE_TOKEN_REAL_ID]		=		9;
	elemento.token_transitions		[26][APE_TOKEN_STRING_ID]		=		9;
	elemento.token_transitions		[27][APE_TOKEN_INICIO_ID]		=		28;
	elemento.token_transitions		[28][APE_TOKEN_FIM_ID]		=		0;
	elemento.token_transitions		[29][APE_TOKEN_FECHA_PARENTESES_ID]		=		25;
	elemento.token_transitions		[29][APE_TOKEN_VIRGULA_ID]		=		32;
	elemento.token_transitions		[30][APE_TOKEN_NUMERO_ID]		=		31;
	elemento.token_transitions		[31][APE_TOKEN_FECHA_COLCHETES_ID]		=		24;
	elemento.token_transitions		[32][APE_TOKEN_BOOLEANO_ID]		=		24;
	elemento.token_transitions		[32][APE_TOKEN_IDENTIFICADOR_ID]		=		24;
	elemento.token_transitions		[32][APE_TOKEN_INTEIRO_ID]		=		24;
	elemento.token_transitions		[32][APE_TOKEN_REAL_ID]		=		24;
	elemento.token_transitions		[32][APE_TOKEN_STRING_ID]		=		24;

	/* machine transitions */
	elemento.machine_transitions		[8][APE_MACHINE_DECLARACAO_ID]		=		8;
	elemento.machine_transitions		[11][APE_MACHINE_COMANDO_ID]		=		11;
	elemento.machine_transitions		[12][APE_MACHINE_DECLARACAO_ID]		=		12;
	elemento.machine_transitions		[14][APE_MACHINE_DECLARACAO_ID]		=		15;
	elemento.machine_transitions		[16][APE_MACHINE_COMANDO_ID]		=		16;
	elemento.machine_transitions		[18][APE_MACHINE_DECLARACAO_ID]		=		18;
	elemento.machine_transitions		[27][APE_MACHINE_DECLARACAO_ID]		=		27;
	elemento.machine_transitions		[28][APE_MACHINE_COMANDO_ID]		=		28;

	/* Machine 1: declaracao */
  declaracao.machine_id = APE_MACHINE_DECLARACAO_ID; // 1
  declaracao.initial_state = 0;
  declaracao.current_state = 0;
  initialize_machine_transitions(&declaracao);
	declaracao.final_states[0] = 6;
	declaracao.final_states[1] = -1;

	/* token transitions */
	declaracao.token_transitions		[0][APE_TOKEN_BOOLEANO_ID]		=		1;
	declaracao.token_transitions		[0][APE_TOKEN_IDENTIFICADOR_ID]		=		1;
	declaracao.token_transitions		[0][APE_TOKEN_INTEIRO_ID]		=		1;
	declaracao.token_transitions		[0][APE_TOKEN_REAL_ID]		=		1;
	declaracao.token_transitions		[0][APE_TOKEN_STRING_ID]		=		1;
	declaracao.token_transitions		[1][APE_TOKEN_ABRE_COLCHETES_ID]		=		3;
	declaracao.token_transitions		[1][APE_TOKEN_IDENTIFICADOR_ID]		=		2;
	declaracao.token_transitions		[2][APE_TOKEN_ATRIBUICAO_ID]		=		5;
	declaracao.token_transitions		[2][APE_TOKEN_PONTO_E_VIRGULA_ID]		=		6;
	declaracao.token_transitions		[3][APE_TOKEN_NUMERO_ID]		=		4;
	declaracao.token_transitions		[4][APE_TOKEN_FECHA_COLCHETES_ID]		=		1;
	declaracao.token_transitions		[7][APE_TOKEN_PONTO_E_VIRGULA_ID]		=		6;

	/* machine transitions */
	declaracao.machine_transitions		[5][APE_MACHINE_EXPRESSAO_ID]		=		7;

	/* Machine 2: comando */
  comando.machine_id = APE_MACHINE_COMANDO_ID; // 2
  comando.initial_state = 0;
  comando.current_state = 0;
  initialize_machine_transitions(&comando);
	comando.final_states[0] = 10;
	comando.final_states[1] = -1;

	/* token transitions */
	comando.token_transitions		[0][APE_TOKEN_ENQUANTO_ID]		=		3;
	comando.token_transitions		[0][APE_TOKEN_ENTRADA_ID]		=		4;
	comando.token_transitions		[0][APE_TOKEN_IDENTIFICADOR_ID]		=		1;
	comando.token_transitions		[0][APE_TOKEN_SAIDA_ID]		=		5;
	comando.token_transitions		[0][APE_TOKEN_SE_ID]		=		2;
	comando.token_transitions		[1][APE_TOKEN_ABRE_COLCHETES_ID]		=		6;
	comando.token_transitions		[1][APE_TOKEN_ABRE_PARENTESES_ID]		=		7;
	comando.token_transitions		[1][APE_TOKEN_ATRIBUICAO_ID]		=		5;
	comando.token_transitions		[4][APE_TOKEN_IDENTIFICADOR_ID]		=		8;
	comando.token_transitions		[6][APE_TOKEN_NUMERO_ID]		=		14;
	comando.token_transitions		[7][APE_TOKEN_FECHA_PARENTESES_ID]		=		8;
	comando.token_transitions		[8][APE_TOKEN_PONTO_E_VIRGULA_ID]		=		10;
	comando.token_transitions		[9][APE_TOKEN_FECHA_PARENTESES_ID]		=		8;
	comando.token_transitions		[9][APE_TOKEN_VIRGULA_ID]		=		11;
	comando.token_transitions		[12][APE_TOKEN_LOOP_ID]		=		13;
	comando.token_transitions		[13][APE_TOKEN_FIMLOOP_ID]		=		10;
	comando.token_transitions		[14][APE_TOKEN_FECHA_COLCHETES_ID]		=		15;
	comando.token_transitions		[15][APE_TOKEN_ABRE_COLCHETES_ID]		=		6;
	comando.token_transitions		[15][APE_TOKEN_ATRIBUICAO_ID]		=		5;
	comando.token_transitions		[16][APE_TOKEN_ENTAO_ID]		=		17;
	comando.token_transitions		[17][APE_TOKEN_FIMSE_ID]		=		10;
	comando.token_transitions		[17][APE_TOKEN_SENAOSE_ID]		=		2;
	comando.token_transitions		[17][APE_TOKEN_SENAO_ID]		=		18;
	comando.token_transitions		[18][APE_TOKEN_FIMSE_ID]		=		10;

	/* machine transitions */
	comando.machine_transitions		[2][APE_MACHINE_EXPRESSAO_ID]		=		16;
	comando.machine_transitions		[3][APE_MACHINE_EXPRESSAO_ID]		=		12;
	comando.machine_transitions		[5][APE_MACHINE_EXPRESSAO_ID]		=		8;
	comando.machine_transitions		[7][APE_MACHINE_EXPRESSAO_ID]		=		9;
	comando.machine_transitions		[11][APE_MACHINE_EXPRESSAO_ID]		=		9;
	comando.machine_transitions		[13][APE_MACHINE_COMANDO_ID]		=		13;
	comando.machine_transitions		[17][APE_MACHINE_COMANDO_ID]		=		17;
	comando.machine_transitions		[18][APE_MACHINE_COMANDO_ID]		=		18;

	/* Machine 3: expressao */
  expressao.machine_id = APE_MACHINE_EXPRESSAO_ID; // 3
  expressao.initial_state = 0;
  expressao.current_state = 0;
  initialize_machine_transitions(&expressao);
	expressao.final_states[0] = 2;
	expressao.final_states[1] = 4;
	expressao.final_states[2] = 11;
	expressao.final_states[3] = 13;
	expressao.final_states[4] = 19;
	expressao.final_states[5] = 21;
	expressao.final_states[6] = 22;
	expressao.final_states[7] = 32;
	expressao.final_states[8] = 33;
	expressao.final_states[9] = 35;
	expressao.final_states[10] = 42;
	expressao.final_states[11] = 45;
	expressao.final_states[12] = 49;
	expressao.final_states[13] = 54;
	expressao.final_states[14] = 56;
	expressao.final_states[15] = 63;
	expressao.final_states[16] = 70;
	expressao.final_states[17] = 74;
	expressao.final_states[18] = 77;
	expressao.final_states[19] = 79;
	expressao.final_states[20] = 83;
	expressao.final_states[21] = 90;
	expressao.final_states[22] = 94;
	expressao.final_states[23] = 96;
	expressao.final_states[24] = 103;
	expressao.final_states[25] = -1;

	/* token transitions */
	expressao.token_transitions		[0][APE_TOKEN_ABRE_PARENTESES_ID]		=		3;
	expressao.token_transitions		[0][APE_TOKEN_FALSO_ID]		=		4;
	expressao.token_transitions		[0][APE_TOKEN_IDENTIFICADOR_ID]		=		2;
	expressao.token_transitions		[0][APE_TOKEN_NUMERO_ID]		=		4;
	expressao.token_transitions		[0][APE_TOKEN_SOMA_ID]		=		1;
	expressao.token_transitions		[0][APE_TOKEN_STRINGLITERAL_ID]		=		4;
	expressao.token_transitions		[0][APE_TOKEN_SUBTRACAO_ID]		=		1;
	expressao.token_transitions		[0][APE_TOKEN_VERDADEIRO_ID]		=		4;
	expressao.token_transitions		[1][APE_TOKEN_ABRE_PARENTESES_ID]		=		3;
	expressao.token_transitions		[1][APE_TOKEN_FALSO_ID]		=		4;
	expressao.token_transitions		[1][APE_TOKEN_IDENTIFICADOR_ID]		=		2;
	expressao.token_transitions		[1][APE_TOKEN_NUMERO_ID]		=		4;
	expressao.token_transitions		[1][APE_TOKEN_STRINGLITERAL_ID]		=		4;
	expressao.token_transitions		[1][APE_TOKEN_VERDADEIRO_ID]		=		4;
	expressao.token_transitions		[2][APE_TOKEN_ABRE_COLCHETES_ID]		=		15;
	expressao.token_transitions		[2][APE_TOKEN_ABRE_PARENTESES_ID]		=		14;
	expressao.token_transitions		[2][APE_TOKEN_DIFERENTE_ID]		=		7;
	expressao.token_transitions		[2][APE_TOKEN_DIVISAO_ID]		=		6;
	expressao.token_transitions		[2][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[2][APE_TOKEN_IGUAL_ID]		=		7;
	expressao.token_transitions		[2][APE_TOKEN_MAIOR_ID]		=		7;
	expressao.token_transitions		[2][APE_TOKEN_MAIOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[2][APE_TOKEN_MENOR_ID]		=		7;
	expressao.token_transitions		[2][APE_TOKEN_MENOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[2][APE_TOKEN_MULTIPLICACAO_ID]		=		6;
	expressao.token_transitions		[2][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[2][APE_TOKEN_SOMA_ID]		=		5;
	expressao.token_transitions		[2][APE_TOKEN_SUBTRACAO_ID]		=		5;
	expressao.token_transitions		[4][APE_TOKEN_DIFERENTE_ID]		=		7;
	expressao.token_transitions		[4][APE_TOKEN_DIVISAO_ID]		=		6;
	expressao.token_transitions		[4][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[4][APE_TOKEN_IGUAL_ID]		=		7;
	expressao.token_transitions		[4][APE_TOKEN_MAIOR_ID]		=		7;
	expressao.token_transitions		[4][APE_TOKEN_MAIOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[4][APE_TOKEN_MENOR_ID]		=		7;
	expressao.token_transitions		[4][APE_TOKEN_MENOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[4][APE_TOKEN_MULTIPLICACAO_ID]		=		6;
	expressao.token_transitions		[4][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[4][APE_TOKEN_SOMA_ID]		=		5;
	expressao.token_transitions		[4][APE_TOKEN_SUBTRACAO_ID]		=		5;
	expressao.token_transitions		[5][APE_TOKEN_ABRE_PARENTESES_ID]		=		34;
	expressao.token_transitions		[5][APE_TOKEN_FALSO_ID]		=		35;
	expressao.token_transitions		[5][APE_TOKEN_IDENTIFICADOR_ID]		=		33;
	expressao.token_transitions		[5][APE_TOKEN_NUMERO_ID]		=		35;
	expressao.token_transitions		[5][APE_TOKEN_STRINGLITERAL_ID]		=		35;
	expressao.token_transitions		[5][APE_TOKEN_VERDADEIRO_ID]		=		35;
	expressao.token_transitions		[6][APE_TOKEN_ABRE_PARENTESES_ID]		=		3;
	expressao.token_transitions		[6][APE_TOKEN_FALSO_ID]		=		4;
	expressao.token_transitions		[6][APE_TOKEN_IDENTIFICADOR_ID]		=		45;
	expressao.token_transitions		[6][APE_TOKEN_NUMERO_ID]		=		4;
	expressao.token_transitions		[6][APE_TOKEN_STRINGLITERAL_ID]		=		4;
	expressao.token_transitions		[6][APE_TOKEN_VERDADEIRO_ID]		=		4;
	expressao.token_transitions		[7][APE_TOKEN_ABRE_PARENTESES_ID]		=		95;
	expressao.token_transitions		[7][APE_TOKEN_FALSO_ID]		=		96;
	expressao.token_transitions		[7][APE_TOKEN_IDENTIFICADOR_ID]		=		94;
	expressao.token_transitions		[7][APE_TOKEN_NUMERO_ID]		=		96;
	expressao.token_transitions		[7][APE_TOKEN_SOMA_ID]		=		93;
	expressao.token_transitions		[7][APE_TOKEN_STRINGLITERAL_ID]		=		96;
	expressao.token_transitions		[7][APE_TOKEN_SUBTRACAO_ID]		=		93;
	expressao.token_transitions		[7][APE_TOKEN_VERDADEIRO_ID]		=		96;
	expressao.token_transitions		[8][APE_TOKEN_ABRE_PARENTESES_ID]		=		78;
	expressao.token_transitions		[8][APE_TOKEN_FALSO_ID]		=		79;
	expressao.token_transitions		[8][APE_TOKEN_IDENTIFICADOR_ID]		=		77;
	expressao.token_transitions		[8][APE_TOKEN_NUMERO_ID]		=		79;
	expressao.token_transitions		[8][APE_TOKEN_SOMA_ID]		=		50;
	expressao.token_transitions		[8][APE_TOKEN_STRINGLITERAL_ID]		=		79;
	expressao.token_transitions		[8][APE_TOKEN_SUBTRACAO_ID]		=		50;
	expressao.token_transitions		[8][APE_TOKEN_VERDADEIRO_ID]		=		79;
	expressao.token_transitions		[9][APE_TOKEN_ABRE_PARENTESES_ID]		=		12;
	expressao.token_transitions		[9][APE_TOKEN_FALSO_ID]		=		13;
	expressao.token_transitions		[9][APE_TOKEN_IDENTIFICADOR_ID]		=		11;
	expressao.token_transitions		[9][APE_TOKEN_NUMERO_ID]		=		13;
	expressao.token_transitions		[9][APE_TOKEN_SOMA_ID]		=		10;
	expressao.token_transitions		[9][APE_TOKEN_STRINGLITERAL_ID]		=		13;
	expressao.token_transitions		[9][APE_TOKEN_SUBTRACAO_ID]		=		10;
	expressao.token_transitions		[9][APE_TOKEN_VERDADEIRO_ID]		=		13;
	expressao.token_transitions		[10][APE_TOKEN_ABRE_PARENTESES_ID]		=		12;
	expressao.token_transitions		[10][APE_TOKEN_FALSO_ID]		=		13;
	expressao.token_transitions		[10][APE_TOKEN_IDENTIFICADOR_ID]		=		11;
	expressao.token_transitions		[10][APE_TOKEN_NUMERO_ID]		=		13;
	expressao.token_transitions		[10][APE_TOKEN_STRINGLITERAL_ID]		=		13;
	expressao.token_transitions		[10][APE_TOKEN_VERDADEIRO_ID]		=		13;
	expressao.token_transitions		[11][APE_TOKEN_ABRE_COLCHETES_ID]		=		68;
	expressao.token_transitions		[11][APE_TOKEN_ABRE_PARENTESES_ID]		=		67;
	expressao.token_transitions		[11][APE_TOKEN_DIFERENTE_ID]		=		16;
	expressao.token_transitions		[11][APE_TOKEN_DIVISAO_ID]		=		10;
	expressao.token_transitions		[11][APE_TOKEN_IGUAL_ID]		=		16;
	expressao.token_transitions		[11][APE_TOKEN_MAIOR_ID]		=		16;
	expressao.token_transitions		[11][APE_TOKEN_MAIOR_IGUAL_ID]		=		16;
	expressao.token_transitions		[11][APE_TOKEN_MENOR_ID]		=		16;
	expressao.token_transitions		[11][APE_TOKEN_MENOR_IGUAL_ID]		=		16;
	expressao.token_transitions		[11][APE_TOKEN_MULTIPLICACAO_ID]		=		10;
	expressao.token_transitions		[11][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[11][APE_TOKEN_SOMA_ID]		=		10;
	expressao.token_transitions		[11][APE_TOKEN_SUBTRACAO_ID]		=		10;
	expressao.token_transitions		[13][APE_TOKEN_DIFERENTE_ID]		=		16;
	expressao.token_transitions		[13][APE_TOKEN_DIVISAO_ID]		=		10;
	expressao.token_transitions		[13][APE_TOKEN_IGUAL_ID]		=		16;
	expressao.token_transitions		[13][APE_TOKEN_MAIOR_ID]		=		16;
	expressao.token_transitions		[13][APE_TOKEN_MAIOR_IGUAL_ID]		=		16;
	expressao.token_transitions		[13][APE_TOKEN_MENOR_ID]		=		16;
	expressao.token_transitions		[13][APE_TOKEN_MENOR_IGUAL_ID]		=		16;
	expressao.token_transitions		[13][APE_TOKEN_MULTIPLICACAO_ID]		=		10;
	expressao.token_transitions		[13][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[13][APE_TOKEN_SOMA_ID]		=		10;
	expressao.token_transitions		[13][APE_TOKEN_SUBTRACAO_ID]		=		10;
	expressao.token_transitions		[14][APE_TOKEN_FECHA_PARENTESES_ID]		=		4;
	expressao.token_transitions		[15][APE_TOKEN_NUMERO_ID]		=		17;
	expressao.token_transitions		[16][APE_TOKEN_ABRE_PARENTESES_ID]		=		20;
	expressao.token_transitions		[16][APE_TOKEN_FALSO_ID]		=		21;
	expressao.token_transitions		[16][APE_TOKEN_IDENTIFICADOR_ID]		=		19;
	expressao.token_transitions		[16][APE_TOKEN_NUMERO_ID]		=		21;
	expressao.token_transitions		[16][APE_TOKEN_SOMA_ID]		=		18;
	expressao.token_transitions		[16][APE_TOKEN_STRINGLITERAL_ID]		=		21;
	expressao.token_transitions		[16][APE_TOKEN_SUBTRACAO_ID]		=		18;
	expressao.token_transitions		[16][APE_TOKEN_VERDADEIRO_ID]		=		21;
	expressao.token_transitions		[17][APE_TOKEN_FECHA_COLCHETES_ID]		=		22;
	expressao.token_transitions		[18][APE_TOKEN_ABRE_PARENTESES_ID]		=		20;
	expressao.token_transitions		[18][APE_TOKEN_FALSO_ID]		=		21;
	expressao.token_transitions		[18][APE_TOKEN_IDENTIFICADOR_ID]		=		19;
	expressao.token_transitions		[18][APE_TOKEN_NUMERO_ID]		=		21;
	expressao.token_transitions		[18][APE_TOKEN_STRINGLITERAL_ID]		=		21;
	expressao.token_transitions		[18][APE_TOKEN_VERDADEIRO_ID]		=		21;
	expressao.token_transitions		[19][APE_TOKEN_ABRE_COLCHETES_ID]		=		30;
	expressao.token_transitions		[19][APE_TOKEN_ABRE_PARENTESES_ID]		=		29;
	expressao.token_transitions		[19][APE_TOKEN_DIVISAO_ID]		=		23;
	expressao.token_transitions		[19][APE_TOKEN_MULTIPLICACAO_ID]		=		23;
	expressao.token_transitions		[19][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[19][APE_TOKEN_SOMA_ID]		=		23;
	expressao.token_transitions		[19][APE_TOKEN_SUBTRACAO_ID]		=		23;
	expressao.token_transitions		[21][APE_TOKEN_DIVISAO_ID]		=		23;
	expressao.token_transitions		[21][APE_TOKEN_MULTIPLICACAO_ID]		=		23;
	expressao.token_transitions		[21][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[21][APE_TOKEN_SOMA_ID]		=		23;
	expressao.token_transitions		[21][APE_TOKEN_SUBTRACAO_ID]		=		23;
	expressao.token_transitions		[22][APE_TOKEN_ABRE_COLCHETES_ID]		=		15;
	expressao.token_transitions		[22][APE_TOKEN_DIFERENTE_ID]		=		7;
	expressao.token_transitions		[22][APE_TOKEN_DIVISAO_ID]		=		6;
	expressao.token_transitions		[22][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[22][APE_TOKEN_IGUAL_ID]		=		7;
	expressao.token_transitions		[22][APE_TOKEN_MAIOR_ID]		=		7;
	expressao.token_transitions		[22][APE_TOKEN_MAIOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[22][APE_TOKEN_MENOR_ID]		=		7;
	expressao.token_transitions		[22][APE_TOKEN_MENOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[22][APE_TOKEN_MULTIPLICACAO_ID]		=		6;
	expressao.token_transitions		[22][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[22][APE_TOKEN_SOMA_ID]		=		5;
	expressao.token_transitions		[22][APE_TOKEN_SUBTRACAO_ID]		=		5;
	expressao.token_transitions		[23][APE_TOKEN_ABRE_PARENTESES_ID]		=		24;
	expressao.token_transitions		[23][APE_TOKEN_FALSO_ID]		=		21;
	expressao.token_transitions		[23][APE_TOKEN_IDENTIFICADOR_ID]		=		19;
	expressao.token_transitions		[23][APE_TOKEN_NUMERO_ID]		=		21;
	expressao.token_transitions		[23][APE_TOKEN_STRINGLITERAL_ID]		=		21;
	expressao.token_transitions		[23][APE_TOKEN_VERDADEIRO_ID]		=		21;
	expressao.token_transitions		[25][APE_TOKEN_FECHA_PARENTESES_ID]		=		4;
	expressao.token_transitions		[25][APE_TOKEN_VIRGULA_ID]		=		26;
	expressao.token_transitions		[27][APE_TOKEN_FECHA_PARENTESES_ID]		=		21;
	expressao.token_transitions		[28][APE_TOKEN_FECHA_PARENTESES_ID]		=		4;
	expressao.token_transitions		[29][APE_TOKEN_FECHA_PARENTESES_ID]		=		21;
	expressao.token_transitions		[30][APE_TOKEN_NUMERO_ID]		=		31;
	expressao.token_transitions		[31][APE_TOKEN_FECHA_COLCHETES_ID]		=		32;
	expressao.token_transitions		[32][APE_TOKEN_ABRE_COLCHETES_ID]		=		30;
	expressao.token_transitions		[32][APE_TOKEN_DIVISAO_ID]		=		23;
	expressao.token_transitions		[32][APE_TOKEN_MULTIPLICACAO_ID]		=		23;
	expressao.token_transitions		[32][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[32][APE_TOKEN_SOMA_ID]		=		23;
	expressao.token_transitions		[32][APE_TOKEN_SUBTRACAO_ID]		=		23;
	expressao.token_transitions		[33][APE_TOKEN_ABRE_COLCHETES_ID]		=		40;
	expressao.token_transitions		[33][APE_TOKEN_ABRE_PARENTESES_ID]		=		39;
	expressao.token_transitions		[33][APE_TOKEN_DIFERENTE_ID]		=		7;
	expressao.token_transitions		[33][APE_TOKEN_DIVISAO_ID]		=		5;
	expressao.token_transitions		[33][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[33][APE_TOKEN_IGUAL_ID]		=		7;
	expressao.token_transitions		[33][APE_TOKEN_MAIOR_ID]		=		7;
	expressao.token_transitions		[33][APE_TOKEN_MAIOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[33][APE_TOKEN_MENOR_ID]		=		7;
	expressao.token_transitions		[33][APE_TOKEN_MENOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[33][APE_TOKEN_MULTIPLICACAO_ID]		=		5;
	expressao.token_transitions		[33][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[33][APE_TOKEN_SOMA_ID]		=		5;
	expressao.token_transitions		[33][APE_TOKEN_SUBTRACAO_ID]		=		5;
	expressao.token_transitions		[35][APE_TOKEN_DIFERENTE_ID]		=		7;
	expressao.token_transitions		[35][APE_TOKEN_DIVISAO_ID]		=		5;
	expressao.token_transitions		[35][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[35][APE_TOKEN_IGUAL_ID]		=		7;
	expressao.token_transitions		[35][APE_TOKEN_MAIOR_ID]		=		7;
	expressao.token_transitions		[35][APE_TOKEN_MAIOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[35][APE_TOKEN_MENOR_ID]		=		7;
	expressao.token_transitions		[35][APE_TOKEN_MENOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[35][APE_TOKEN_MULTIPLICACAO_ID]		=		5;
	expressao.token_transitions		[35][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[35][APE_TOKEN_SOMA_ID]		=		5;
	expressao.token_transitions		[35][APE_TOKEN_SUBTRACAO_ID]		=		5;
	expressao.token_transitions		[36][APE_TOKEN_FECHA_PARENTESES_ID]		=		21;
	expressao.token_transitions		[36][APE_TOKEN_VIRGULA_ID]		=		37;
	expressao.token_transitions		[38][APE_TOKEN_FECHA_PARENTESES_ID]		=		35;
	expressao.token_transitions		[39][APE_TOKEN_FECHA_PARENTESES_ID]		=		35;
	expressao.token_transitions		[40][APE_TOKEN_NUMERO_ID]		=		41;
	expressao.token_transitions		[41][APE_TOKEN_FECHA_COLCHETES_ID]		=		42;
	expressao.token_transitions		[42][APE_TOKEN_ABRE_COLCHETES_ID]		=		40;
	expressao.token_transitions		[42][APE_TOKEN_DIFERENTE_ID]		=		7;
	expressao.token_transitions		[42][APE_TOKEN_DIVISAO_ID]		=		5;
	expressao.token_transitions		[42][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[42][APE_TOKEN_IGUAL_ID]		=		7;
	expressao.token_transitions		[42][APE_TOKEN_MAIOR_ID]		=		7;
	expressao.token_transitions		[42][APE_TOKEN_MAIOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[42][APE_TOKEN_MENOR_ID]		=		7;
	expressao.token_transitions		[42][APE_TOKEN_MENOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[42][APE_TOKEN_MULTIPLICACAO_ID]		=		5;
	expressao.token_transitions		[42][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[42][APE_TOKEN_SOMA_ID]		=		5;
	expressao.token_transitions		[42][APE_TOKEN_SUBTRACAO_ID]		=		5;
	expressao.token_transitions		[43][APE_TOKEN_FECHA_PARENTESES_ID]		=		35;
	expressao.token_transitions		[43][APE_TOKEN_VIRGULA_ID]		=		44;
	expressao.token_transitions		[45][APE_TOKEN_ABRE_COLCHETES_ID]		=		15;
	expressao.token_transitions		[45][APE_TOKEN_ABRE_PARENTESES_ID]		=		46;
	expressao.token_transitions		[45][APE_TOKEN_DIFERENTE_ID]		=		7;
	expressao.token_transitions		[45][APE_TOKEN_DIVISAO_ID]		=		6;
	expressao.token_transitions		[45][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[45][APE_TOKEN_IGUAL_ID]		=		7;
	expressao.token_transitions		[45][APE_TOKEN_MAIOR_ID]		=		7;
	expressao.token_transitions		[45][APE_TOKEN_MAIOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[45][APE_TOKEN_MENOR_ID]		=		7;
	expressao.token_transitions		[45][APE_TOKEN_MENOR_IGUAL_ID]		=		7;
	expressao.token_transitions		[45][APE_TOKEN_MULTIPLICACAO_ID]		=		6;
	expressao.token_transitions		[45][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[45][APE_TOKEN_SOMA_ID]		=		5;
	expressao.token_transitions		[45][APE_TOKEN_SUBTRACAO_ID]		=		5;
	expressao.token_transitions		[46][APE_TOKEN_FECHA_PARENTESES_ID]		=		49;
	expressao.token_transitions		[47][APE_TOKEN_FECHA_PARENTESES_ID]		=		21;
	expressao.token_transitions		[48][APE_TOKEN_FECHA_PARENTESES_ID]		=		49;
	expressao.token_transitions		[48][APE_TOKEN_VIRGULA_ID]		=		106;
	expressao.token_transitions		[49][APE_TOKEN_DIFERENTE_ID]		=		52;
	expressao.token_transitions		[49][APE_TOKEN_DIVISAO_ID]		=		51;
	expressao.token_transitions		[49][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[49][APE_TOKEN_IGUAL_ID]		=		52;
	expressao.token_transitions		[49][APE_TOKEN_MAIOR_ID]		=		52;
	expressao.token_transitions		[49][APE_TOKEN_MAIOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[49][APE_TOKEN_MENOR_ID]		=		52;
	expressao.token_transitions		[49][APE_TOKEN_MENOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[49][APE_TOKEN_MULTIPLICACAO_ID]		=		51;
	expressao.token_transitions		[49][APE_TOKEN_SOMA_ID]		=		50;
	expressao.token_transitions		[49][APE_TOKEN_SUBTRACAO_ID]		=		50;
	expressao.token_transitions		[50][APE_TOKEN_ABRE_PARENTESES_ID]		=		78;
	expressao.token_transitions		[50][APE_TOKEN_FALSO_ID]		=		79;
	expressao.token_transitions		[50][APE_TOKEN_IDENTIFICADOR_ID]		=		77;
	expressao.token_transitions		[50][APE_TOKEN_NUMERO_ID]		=		79;
	expressao.token_transitions		[50][APE_TOKEN_STRINGLITERAL_ID]		=		79;
	expressao.token_transitions		[50][APE_TOKEN_VERDADEIRO_ID]		=		79;
	expressao.token_transitions		[51][APE_TOKEN_ABRE_PARENTESES_ID]		=		75;
	expressao.token_transitions		[51][APE_TOKEN_FALSO_ID]		=		49;
	expressao.token_transitions		[51][APE_TOKEN_IDENTIFICADOR_ID]		=		74;
	expressao.token_transitions		[51][APE_TOKEN_NUMERO_ID]		=		49;
	expressao.token_transitions		[51][APE_TOKEN_STRINGLITERAL_ID]		=		49;
	expressao.token_transitions		[51][APE_TOKEN_VERDADEIRO_ID]		=		49;
	expressao.token_transitions		[52][APE_TOKEN_ABRE_PARENTESES_ID]		=		55;
	expressao.token_transitions		[52][APE_TOKEN_FALSO_ID]		=		56;
	expressao.token_transitions		[52][APE_TOKEN_IDENTIFICADOR_ID]		=		54;
	expressao.token_transitions		[52][APE_TOKEN_NUMERO_ID]		=		56;
	expressao.token_transitions		[52][APE_TOKEN_SOMA_ID]		=		53;
	expressao.token_transitions		[52][APE_TOKEN_STRINGLITERAL_ID]		=		56;
	expressao.token_transitions		[52][APE_TOKEN_SUBTRACAO_ID]		=		53;
	expressao.token_transitions		[52][APE_TOKEN_VERDADEIRO_ID]		=		56;
	expressao.token_transitions		[53][APE_TOKEN_ABRE_PARENTESES_ID]		=		55;
	expressao.token_transitions		[53][APE_TOKEN_FALSO_ID]		=		56;
	expressao.token_transitions		[53][APE_TOKEN_IDENTIFICADOR_ID]		=		54;
	expressao.token_transitions		[53][APE_TOKEN_NUMERO_ID]		=		56;
	expressao.token_transitions		[53][APE_TOKEN_STRINGLITERAL_ID]		=		56;
	expressao.token_transitions		[53][APE_TOKEN_VERDADEIRO_ID]		=		56;
	expressao.token_transitions		[54][APE_TOKEN_ABRE_COLCHETES_ID]		=		61;
	expressao.token_transitions		[54][APE_TOKEN_ABRE_PARENTESES_ID]		=		60;
	expressao.token_transitions		[54][APE_TOKEN_DIVISAO_ID]		=		57;
	expressao.token_transitions		[54][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[54][APE_TOKEN_MULTIPLICACAO_ID]		=		57;
	expressao.token_transitions		[54][APE_TOKEN_SOMA_ID]		=		57;
	expressao.token_transitions		[54][APE_TOKEN_SUBTRACAO_ID]		=		57;
	expressao.token_transitions		[56][APE_TOKEN_DIVISAO_ID]		=		57;
	expressao.token_transitions		[56][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[56][APE_TOKEN_MULTIPLICACAO_ID]		=		57;
	expressao.token_transitions		[56][APE_TOKEN_SOMA_ID]		=		57;
	expressao.token_transitions		[56][APE_TOKEN_SUBTRACAO_ID]		=		57;
	expressao.token_transitions		[57][APE_TOKEN_ABRE_PARENTESES_ID]		=		58;
	expressao.token_transitions		[57][APE_TOKEN_FALSO_ID]		=		56;
	expressao.token_transitions		[57][APE_TOKEN_IDENTIFICADOR_ID]		=		54;
	expressao.token_transitions		[57][APE_TOKEN_NUMERO_ID]		=		56;
	expressao.token_transitions		[57][APE_TOKEN_STRINGLITERAL_ID]		=		56;
	expressao.token_transitions		[57][APE_TOKEN_VERDADEIRO_ID]		=		56;
	expressao.token_transitions		[59][APE_TOKEN_FECHA_PARENTESES_ID]		=		56;
	expressao.token_transitions		[60][APE_TOKEN_FECHA_PARENTESES_ID]		=		56;
	expressao.token_transitions		[61][APE_TOKEN_NUMERO_ID]		=		62;
	expressao.token_transitions		[62][APE_TOKEN_FECHA_COLCHETES_ID]		=		63;
	expressao.token_transitions		[63][APE_TOKEN_ABRE_COLCHETES_ID]		=		61;
	expressao.token_transitions		[63][APE_TOKEN_DIVISAO_ID]		=		57;
	expressao.token_transitions		[63][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[63][APE_TOKEN_MULTIPLICACAO_ID]		=		57;
	expressao.token_transitions		[63][APE_TOKEN_SOMA_ID]		=		57;
	expressao.token_transitions		[63][APE_TOKEN_SUBTRACAO_ID]		=		57;
	expressao.token_transitions		[64][APE_TOKEN_FECHA_PARENTESES_ID]		=		56;
	expressao.token_transitions		[64][APE_TOKEN_VIRGULA_ID]		=		65;
	expressao.token_transitions		[66][APE_TOKEN_FECHA_PARENTESES_ID]		=		13;
	expressao.token_transitions		[67][APE_TOKEN_FECHA_PARENTESES_ID]		=		13;
	expressao.token_transitions		[68][APE_TOKEN_NUMERO_ID]		=		69;
	expressao.token_transitions		[69][APE_TOKEN_FECHA_COLCHETES_ID]		=		70;
	expressao.token_transitions		[70][APE_TOKEN_ABRE_COLCHETES_ID]		=		68;
	expressao.token_transitions		[70][APE_TOKEN_DIFERENTE_ID]		=		16;
	expressao.token_transitions		[70][APE_TOKEN_DIVISAO_ID]		=		10;
	expressao.token_transitions		[70][APE_TOKEN_IGUAL_ID]		=		16;
	expressao.token_transitions		[70][APE_TOKEN_MAIOR_ID]		=		16;
	expressao.token_transitions		[70][APE_TOKEN_MAIOR_IGUAL_ID]		=		16;
	expressao.token_transitions		[70][APE_TOKEN_MENOR_ID]		=		16;
	expressao.token_transitions		[70][APE_TOKEN_MENOR_IGUAL_ID]		=		16;
	expressao.token_transitions		[70][APE_TOKEN_MULTIPLICACAO_ID]		=		10;
	expressao.token_transitions		[70][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[70][APE_TOKEN_SOMA_ID]		=		10;
	expressao.token_transitions		[70][APE_TOKEN_SUBTRACAO_ID]		=		10;
	expressao.token_transitions		[71][APE_TOKEN_FECHA_PARENTESES_ID]		=		13;
	expressao.token_transitions		[71][APE_TOKEN_VIRGULA_ID]		=		72;
	expressao.token_transitions		[73][APE_TOKEN_FECHA_PARENTESES_ID]		=		56;
	expressao.token_transitions		[74][APE_TOKEN_ABRE_COLCHETES_ID]		=		81;
	expressao.token_transitions		[74][APE_TOKEN_ABRE_PARENTESES_ID]		=		80;
	expressao.token_transitions		[74][APE_TOKEN_DIFERENTE_ID]		=		52;
	expressao.token_transitions		[74][APE_TOKEN_DIVISAO_ID]		=		51;
	expressao.token_transitions		[74][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[74][APE_TOKEN_IGUAL_ID]		=		52;
	expressao.token_transitions		[74][APE_TOKEN_MAIOR_ID]		=		52;
	expressao.token_transitions		[74][APE_TOKEN_MAIOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[74][APE_TOKEN_MENOR_ID]		=		52;
	expressao.token_transitions		[74][APE_TOKEN_MENOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[74][APE_TOKEN_MULTIPLICACAO_ID]		=		51;
	expressao.token_transitions		[74][APE_TOKEN_SOMA_ID]		=		50;
	expressao.token_transitions		[74][APE_TOKEN_SUBTRACAO_ID]		=		50;
	expressao.token_transitions		[76][APE_TOKEN_FECHA_PARENTESES_ID]		=		49;
	expressao.token_transitions		[77][APE_TOKEN_ABRE_COLCHETES_ID]		=		88;
	expressao.token_transitions		[77][APE_TOKEN_ABRE_PARENTESES_ID]		=		87;
	expressao.token_transitions		[77][APE_TOKEN_DIFERENTE_ID]		=		52;
	expressao.token_transitions		[77][APE_TOKEN_DIVISAO_ID]		=		50;
	expressao.token_transitions		[77][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[77][APE_TOKEN_IGUAL_ID]		=		52;
	expressao.token_transitions		[77][APE_TOKEN_MAIOR_ID]		=		52;
	expressao.token_transitions		[77][APE_TOKEN_MAIOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[77][APE_TOKEN_MENOR_ID]		=		52;
	expressao.token_transitions		[77][APE_TOKEN_MENOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[77][APE_TOKEN_MULTIPLICACAO_ID]		=		50;
	expressao.token_transitions		[77][APE_TOKEN_SOMA_ID]		=		50;
	expressao.token_transitions		[77][APE_TOKEN_SUBTRACAO_ID]		=		50;
	expressao.token_transitions		[79][APE_TOKEN_DIFERENTE_ID]		=		52;
	expressao.token_transitions		[79][APE_TOKEN_DIVISAO_ID]		=		50;
	expressao.token_transitions		[79][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[79][APE_TOKEN_IGUAL_ID]		=		52;
	expressao.token_transitions		[79][APE_TOKEN_MAIOR_ID]		=		52;
	expressao.token_transitions		[79][APE_TOKEN_MAIOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[79][APE_TOKEN_MENOR_ID]		=		52;
	expressao.token_transitions		[79][APE_TOKEN_MENOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[79][APE_TOKEN_MULTIPLICACAO_ID]		=		50;
	expressao.token_transitions		[79][APE_TOKEN_SOMA_ID]		=		50;
	expressao.token_transitions		[79][APE_TOKEN_SUBTRACAO_ID]		=		50;
	expressao.token_transitions		[80][APE_TOKEN_FECHA_PARENTESES_ID]		=		49;
	expressao.token_transitions		[81][APE_TOKEN_NUMERO_ID]		=		82;
	expressao.token_transitions		[82][APE_TOKEN_FECHA_COLCHETES_ID]		=		83;
	expressao.token_transitions		[83][APE_TOKEN_ABRE_COLCHETES_ID]		=		81;
	expressao.token_transitions		[83][APE_TOKEN_DIFERENTE_ID]		=		52;
	expressao.token_transitions		[83][APE_TOKEN_DIVISAO_ID]		=		51;
	expressao.token_transitions		[83][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[83][APE_TOKEN_IGUAL_ID]		=		52;
	expressao.token_transitions		[83][APE_TOKEN_MAIOR_ID]		=		52;
	expressao.token_transitions		[83][APE_TOKEN_MAIOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[83][APE_TOKEN_MENOR_ID]		=		52;
	expressao.token_transitions		[83][APE_TOKEN_MENOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[83][APE_TOKEN_MULTIPLICACAO_ID]		=		51;
	expressao.token_transitions		[83][APE_TOKEN_SOMA_ID]		=		50;
	expressao.token_transitions		[83][APE_TOKEN_SUBTRACAO_ID]		=		50;
	expressao.token_transitions		[84][APE_TOKEN_FECHA_PARENTESES_ID]		=		49;
	expressao.token_transitions		[84][APE_TOKEN_VIRGULA_ID]		=		85;
	expressao.token_transitions		[86][APE_TOKEN_FECHA_PARENTESES_ID]		=		79;
	expressao.token_transitions		[87][APE_TOKEN_FECHA_PARENTESES_ID]		=		79;
	expressao.token_transitions		[88][APE_TOKEN_NUMERO_ID]		=		89;
	expressao.token_transitions		[89][APE_TOKEN_FECHA_COLCHETES_ID]		=		90;
	expressao.token_transitions		[90][APE_TOKEN_ABRE_COLCHETES_ID]		=		88;
	expressao.token_transitions		[90][APE_TOKEN_DIFERENTE_ID]		=		52;
	expressao.token_transitions		[90][APE_TOKEN_DIVISAO_ID]		=		50;
	expressao.token_transitions		[90][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[90][APE_TOKEN_IGUAL_ID]		=		52;
	expressao.token_transitions		[90][APE_TOKEN_MAIOR_ID]		=		52;
	expressao.token_transitions		[90][APE_TOKEN_MAIOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[90][APE_TOKEN_MENOR_ID]		=		52;
	expressao.token_transitions		[90][APE_TOKEN_MENOR_IGUAL_ID]		=		52;
	expressao.token_transitions		[90][APE_TOKEN_MULTIPLICACAO_ID]		=		50;
	expressao.token_transitions		[90][APE_TOKEN_SOMA_ID]		=		50;
	expressao.token_transitions		[90][APE_TOKEN_SUBTRACAO_ID]		=		50;
	expressao.token_transitions		[91][APE_TOKEN_FECHA_PARENTESES_ID]		=		79;
	expressao.token_transitions		[91][APE_TOKEN_VIRGULA_ID]		=		92;
	expressao.token_transitions		[93][APE_TOKEN_ABRE_PARENTESES_ID]		=		95;
	expressao.token_transitions		[93][APE_TOKEN_FALSO_ID]		=		96;
	expressao.token_transitions		[93][APE_TOKEN_IDENTIFICADOR_ID]		=		94;
	expressao.token_transitions		[93][APE_TOKEN_NUMERO_ID]		=		96;
	expressao.token_transitions		[93][APE_TOKEN_STRINGLITERAL_ID]		=		96;
	expressao.token_transitions		[93][APE_TOKEN_VERDADEIRO_ID]		=		96;
	expressao.token_transitions		[94][APE_TOKEN_ABRE_COLCHETES_ID]		=		101;
	expressao.token_transitions		[94][APE_TOKEN_ABRE_PARENTESES_ID]		=		100;
	expressao.token_transitions		[94][APE_TOKEN_DIVISAO_ID]		=		97;
	expressao.token_transitions		[94][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[94][APE_TOKEN_MULTIPLICACAO_ID]		=		97;
	expressao.token_transitions		[94][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[94][APE_TOKEN_SOMA_ID]		=		97;
	expressao.token_transitions		[94][APE_TOKEN_SUBTRACAO_ID]		=		97;
	expressao.token_transitions		[96][APE_TOKEN_DIVISAO_ID]		=		97;
	expressao.token_transitions		[96][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[96][APE_TOKEN_MULTIPLICACAO_ID]		=		97;
	expressao.token_transitions		[96][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[96][APE_TOKEN_SOMA_ID]		=		97;
	expressao.token_transitions		[96][APE_TOKEN_SUBTRACAO_ID]		=		97;
	expressao.token_transitions		[97][APE_TOKEN_ABRE_PARENTESES_ID]		=		98;
	expressao.token_transitions		[97][APE_TOKEN_FALSO_ID]		=		96;
	expressao.token_transitions		[97][APE_TOKEN_IDENTIFICADOR_ID]		=		94;
	expressao.token_transitions		[97][APE_TOKEN_NUMERO_ID]		=		96;
	expressao.token_transitions		[97][APE_TOKEN_STRINGLITERAL_ID]		=		96;
	expressao.token_transitions		[97][APE_TOKEN_VERDADEIRO_ID]		=		96;
	expressao.token_transitions		[99][APE_TOKEN_FECHA_PARENTESES_ID]		=		96;
	expressao.token_transitions		[100][APE_TOKEN_FECHA_PARENTESES_ID]		=		96;
	expressao.token_transitions		[101][APE_TOKEN_NUMERO_ID]		=		102;
	expressao.token_transitions		[102][APE_TOKEN_FECHA_COLCHETES_ID]		=		103;
	expressao.token_transitions		[103][APE_TOKEN_ABRE_COLCHETES_ID]		=		101;
	expressao.token_transitions		[103][APE_TOKEN_DIVISAO_ID]		=		97;
	expressao.token_transitions		[103][APE_TOKEN_E_ID]		=		8;
	expressao.token_transitions		[103][APE_TOKEN_MULTIPLICACAO_ID]		=		97;
	expressao.token_transitions		[103][APE_TOKEN_OU_ID]		=		9;
	expressao.token_transitions		[103][APE_TOKEN_SOMA_ID]		=		97;
	expressao.token_transitions		[103][APE_TOKEN_SUBTRACAO_ID]		=		97;
	expressao.token_transitions		[104][APE_TOKEN_FECHA_PARENTESES_ID]		=		96;
	expressao.token_transitions		[104][APE_TOKEN_VIRGULA_ID]		=		105;
	expressao.token_transitions		[107][APE_TOKEN_FECHA_PARENTESES_ID]		=		96;

	/* machine transitions */
	expressao.machine_transitions		[3][APE_MACHINE_EXPRESSAO_ID]		=		28;
	expressao.machine_transitions		[12][APE_MACHINE_EXPRESSAO_ID]		=		66;
	expressao.machine_transitions		[14][APE_MACHINE_EXPRESSAO_ID]		=		25;
	expressao.machine_transitions		[20][APE_MACHINE_EXPRESSAO_ID]		=		47;
	expressao.machine_transitions		[24][APE_MACHINE_EXPRESSAO_ID]		=		27;
	expressao.machine_transitions		[26][APE_MACHINE_EXPRESSAO_ID]		=		25;
	expressao.machine_transitions		[29][APE_MACHINE_EXPRESSAO_ID]		=		36;
	expressao.machine_transitions		[34][APE_MACHINE_EXPRESSAO_ID]		=		38;
	expressao.machine_transitions		[37][APE_MACHINE_EXPRESSAO_ID]		=		36;
	expressao.machine_transitions		[39][APE_MACHINE_EXPRESSAO_ID]		=		43;
	expressao.machine_transitions		[44][APE_MACHINE_EXPRESSAO_ID]		=		43;
	expressao.machine_transitions		[46][APE_MACHINE_EXPRESSAO_ID]		=		48;
	expressao.machine_transitions		[55][APE_MACHINE_EXPRESSAO_ID]		=		73;
	expressao.machine_transitions		[58][APE_MACHINE_EXPRESSAO_ID]		=		59;
	expressao.machine_transitions		[60][APE_MACHINE_EXPRESSAO_ID]		=		64;
	expressao.machine_transitions		[65][APE_MACHINE_EXPRESSAO_ID]		=		64;
	expressao.machine_transitions		[67][APE_MACHINE_EXPRESSAO_ID]		=		71;
	expressao.machine_transitions		[72][APE_MACHINE_EXPRESSAO_ID]		=		71;
	expressao.machine_transitions		[75][APE_MACHINE_EXPRESSAO_ID]		=		76;
	expressao.machine_transitions		[78][APE_MACHINE_EXPRESSAO_ID]		=		86;
	expressao.machine_transitions		[80][APE_MACHINE_EXPRESSAO_ID]		=		84;
	expressao.machine_transitions		[85][APE_MACHINE_EXPRESSAO_ID]		=		84;
	expressao.machine_transitions		[87][APE_MACHINE_EXPRESSAO_ID]		=		91;
	expressao.machine_transitions		[92][APE_MACHINE_EXPRESSAO_ID]		=		91;
	expressao.machine_transitions		[95][APE_MACHINE_EXPRESSAO_ID]		=		107;
	expressao.machine_transitions		[98][APE_MACHINE_EXPRESSAO_ID]		=		99;
	expressao.machine_transitions		[100][APE_MACHINE_EXPRESSAO_ID]		=		104;
	expressao.machine_transitions		[105][APE_MACHINE_EXPRESSAO_ID]		=		104;
	expressao.machine_transitions		[106][APE_MACHINE_EXPRESSAO_ID]		=		48;

  /* initialize ape machines */
  ape_parser.initial_machine = elemento;
  ape_parser.current_machine = elemento;
	ape_parser.machines[0] = elemento;
	ape_parser.machines[1] = declaracao;
	ape_parser.machines[2] = comando;
	ape_parser.machines[3] = expressao;
}

//////////////////////////////////////////////////////////
